home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 525 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Problem with stringcopy
  5. Date: 6 Jan 1996 09:05 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <6JAN199609050601@erich.triumf.ca>
  9. References: <4clguu$9fs@eagle.novo.dk>
  10. NNTP-Posting-Host: ftp.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <4clguu$9fs@eagle.novo.dk>, morb@novo.dk (Morten Brun) writes...
  14. >How do i do a partial stringcopy i.e. copy from a specific position in
  15. >a string and a certain numbers of bytes. I am looking for a function
  16. >like target = Stringcopy(source, startpos, length)
  17. >Can anybody help please.
  18.  
  19. Try strncpy(dest, source, size)
  20.  
  21. If you want to copy 5 chars starting at the 10th char, do something like:
  22.     strcpy(dest, source+10, 5);
  23.  
  24. There are several string functions starting with "strn" that deal with a
  25. specified number of chars, rather than with the whole string.
  26.  
  27.  
  28. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  29. Internet: bennett@triumf.ca         | of one another only when one can be
  30. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  31. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  32. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  33.  
  34.